<?php

/*

Desktopd Logger
Copyright (C) 2015  Desktopd Developer(s)

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

https://www.gnu.org/licenses/agpl.html

*/


namespace Desktopd\PlatformTools;


abstract class Logger {
    const EMERG = 0; // system is unusable
	const EMERGENCY = self::EMERG;
	
	const ALERT = 1; // action must be taken immediately
	
	const CRIT = 2; // critical conditions
	const CRITICAL = self::CRIT;
	
	const ERR = 3; // error conditions
	const ERROR = self::ERR;
	
	const WARNING = 4; // warning conditions
	const WARN = self::WARNING;
	
	const NOTICE = 5; // normal, but significant, condition
	
	const INFO = 6; // informational message
	const INFORMATION = self::INFO;
	const INFORMATIONAL = self::INFO;
	
	const DEBUG = 7; // debug-level message
	const DBG = self::DEBUG;
	
	const DEBUG2 = 8; // debug-level message
	const DBG2 = self::DEBUG2;
	
	const UNKNOWN = PHP_INT_MAX;
	
	
    abstract public function log ($message, $level = self::INFO);
    
    
	protected function processLogLevel ($level) {
		$level = "$level";
		if (!is_numeric($level)) $level = self::UNKNOWN;
		if ($level > 8 || $level < 0) $level = self::UNKNOWN;
		return round(max(0, min(8, $level)));
	}
}


// vim: ts=4 et ai

